yavsc/Yavsc/Models/HairCut/HairCutQuery.cs

341 lines
14 KiB
C#
Raw Normal View History

2017-02-23 03:10:30 +01:00
2017-02-27 19:28:32 +01:00
using System;
2017-05-12 12:15:57 +02:00
using System.Collections.Generic;
2017-02-13 01:32:03 +01:00
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Models.Billing;
2017-02-27 19:28:32 +01:00
using Yavsc.Models.Relationship;
2017-05-27 16:22:58 +02:00
using Yavsc.Billing;
2017-02-13 01:32:03 +01:00
namespace Yavsc.Models.Haircut
{
2017-04-08 00:32:23 +02:00
public class HairCutQuery : NominativeServiceCommand
2017-02-13 01:32:03 +01:00
{
2017-05-12 12:15:57 +02:00
2017-05-05 23:37:07 +02:00
// Bill description
public override string Description
{
get;
set;
2017-05-12 12:15:57 +02:00
}
= "Prestation en coiffure à domicile";
2017-05-05 23:37:07 +02:00
2017-02-13 01:32:03 +01:00
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
2017-05-05 23:37:07 +02:00
override public long Id { get; set; }
2017-03-02 13:25:20 +01:00
[Required]
public long PrestationId { get; set; }
2017-05-12 12:15:57 +02:00
[ForeignKey("PrestationId"), Required, Display(Name = "Préstation")]
public virtual HairPrestation Prestation { get; set; }
2017-03-02 13:25:20 +01:00
2017-04-01 02:14:10 +02:00
[ForeignKey("LocationId")]
2017-05-12 12:15:57 +02:00
[Display(Name = "Lieu du rendez-vous")]
2017-04-08 17:51:31 +02:00
[DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "[Pas de lieu spécifié]")]
2017-05-12 12:15:57 +02:00
public virtual Location Location { get; set; }
2017-02-27 19:28:32 +01:00
2017-05-12 12:15:57 +02:00
[Display(Name = "Date et heure")]
[DisplayFormat(NullDisplayText = "[Pas de date ni heure]", ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
public DateTime? EventDate
2017-02-27 19:28:32 +01:00
{
get;
set;
}
2017-03-23 00:44:27 +01:00
2017-04-01 02:14:10 +02:00
public long? LocationId
2017-03-23 00:44:27 +01:00
{
get;
set;
}
2017-04-08 09:17:15 +02:00
2017-05-12 12:15:57 +02:00
[Display(Name = "Informations complémentaires"),
2017-04-08 09:17:15 +02:00
StringLengthAttribute(512)]
2017-04-08 17:51:31 +02:00
[DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "[pas d'informations complémentaires]")]
2017-04-08 09:17:15 +02:00
public string AdditionalInfo { get; set; }
2017-05-12 12:15:57 +02:00
public override List<IBillItem> GetBillItems()
{
string longhairsuffix = " (cheveux longs)";
string halflonghairsuffix = " (cheveux mi-longs)";
string shorthairsuffix = " (cheveux courts)";
List<IBillItem> bill = new List<IBillItem>();
2017-05-12 16:29:47 +02:00
#if DEBUG
if (this.Prestation==null) throw new InvalidOperationException("Prestation");
if (this.SelectedProfile==null) throw new InvalidOperationException("SelectedProfile");
#endif
2017-05-12 12:15:57 +02:00
// Le shampoing
if (this.Prestation.Shampoo)
bill.Add(new CommandLine { Name = "Shampoing", UnitaryCost = SelectedProfile.ShampooPrice });
// la coupe
if (Prestation.Cut)
bill.Add(new CommandLine
{
Name = "Coupe",
UnitaryCost =
Prestation.Gender == HairCutGenders.Women ?
Prestation.Length == HairLength.Long ? SelectedProfile.WomenLongCutPrice :
Prestation.Length == HairLength.HalfLong ? SelectedProfile.WomenHalfCutPrice :
SelectedProfile.WomenShortCutPrice : Prestation.Gender == HairCutGenders.Man ?
SelectedProfile.ManCutPrice : SelectedProfile.KidCutPrice
});
// Les techniques
switch (Prestation.Tech)
{
case HairTechnos.Color:
{
bool multicolor = Prestation.Taints.Count > 1;
string name = multicolor ? "Couleur" : "Multi-couleur";
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name + longhairsuffix,
UnitaryCost = multicolor ? SelectedProfile.LongMultiColorPrice :
SelectedProfile.LongColorPrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name + halflonghairsuffix,
UnitaryCost = multicolor ? SelectedProfile.HalfMultiColorPrice : SelectedProfile.HalfColorPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = multicolor ? SelectedProfile.ShortMultiColorPrice : SelectedProfile.ShortColorPrice
});
break;
}
}
break;
case HairTechnos.Balayage:
{
string name = "Balayage";
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongBalayagePrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfBalayagePrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortBalayagePrice
});
break;
}
}
break;
case HairTechnos.Defris:
{
string name = "Defrisage";
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongDefrisPrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfDefrisPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortDefrisPrice
});
break;
}
}
break;
case HairTechnos.Mech:
{
string name = "Mèches";
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongMechPrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfMechPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortMechPrice
});
break;
}
}
break;
case HairTechnos.Permanent:
{
string name = "Mèches";
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongPermanentPrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfPermanentPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortPermanentPrice
});
break;
}
}
break;
}
// Les coiffages
switch (Prestation.Dressing)
{
case HairDressings.Brushing:
{
string name = "Brushing";
switch (Prestation.Gender)
{
case HairCutGenders.Women:
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongBrushingPrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfBrushingPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortBrushingPrice
});
break;
}
break;
case HairCutGenders.Man:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ManBrushPrice
});
break;
}
}
break;
case HairDressings.Coiffage:
// est offert
2017-05-12 16:29:47 +02:00
/* bill.Add(new CommandLine
2017-05-12 12:15:57 +02:00
{
Name = "Coiffage (offert)",
UnitaryCost = 0m
2017-05-12 16:29:47 +02:00
}); */
2017-05-12 12:15:57 +02:00
break;
case HairDressings.Folding:
{
string name = "Mise en plis";
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongFoldingPrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfFoldingPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortFoldingPrice
});
break;
}
}
break;
}
// les soins
if (Prestation.Cares) {
bill.Add(new CommandLine { Name = "Soins",
UnitaryCost = SelectedProfile.CarePrice });
}
return bill;
}
public virtual BrusherProfile SelectedProfile { get; set; }
2017-02-13 01:32:03 +01:00
}
2017-03-23 00:44:27 +01:00
}