// Save Item public RentalItemResponse SaveRentalItem(RentalItemRequest request) { var response = new RentalItemResponse(); if (request.RentalItem != null) { RentalItem rentalItem = null; // Check if Edit or Add if (request.RentalItem.Id > 0) { // Edit rentalItem = Olympus._Enterprise.RentalItems.Where(x => x.Id == request.RentalItem.Id).SingleOrDefault(); if (rentalItem != null) { // Overrides the DateCreated request.RentalItem.DateCreated = rentalItem.DateCreated; Mapper.Map(request.RentalItem, rentalItem); } } else { // Add if (request.RentalItem.Code != null) { // Check some info from AlienDB rentalItem = new RentalItem(); Mapper.Map(request.RentalItem, rentalItem); Olympus._Enterprise.RentalItems.AddObject(rentalItem); } } Olympus._Enterprise.SaveChanges(); if (rentalItem != null) response.RentalItemId = rentalItem.Id; } return response; }
/// <summary> /// Create a new RentalItem object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="code">Initial value of the Code property.</param> /// <param name="cost">Initial value of the Cost property.</param> /// <param name="price">Initial value of the Price property.</param> /// <param name="monthlyPrice">Initial value of the MonthlyPrice property.</param> /// <param name="fortnightPrice">Initial value of the FortnightPrice property.</param> /// <param name="weeklyPrice">Initial value of the WeeklyPrice property.</param> /// <param name="dailyPrice">Initial value of the DailyPrice property.</param> /// <param name="isTaxed">Initial value of the IsTaxed property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> /// <param name="dateModified">Initial value of the DateModified property.</param> /// <param name="maximunDiscount">Initial value of the MaximunDiscount property.</param> /// <param name="wasDeleted">Initial value of the WasDeleted property.</param> /// <param name="familyId">Initial value of the FamilyId property.</param> public static RentalItem CreateRentalItem(global::System.Int32 id, global::System.String name, global::System.String code, global::System.Decimal cost, global::System.Decimal price, global::System.Decimal monthlyPrice, global::System.Decimal fortnightPrice, global::System.Decimal weeklyPrice, global::System.Decimal dailyPrice, global::System.Boolean isTaxed, global::System.DateTime dateCreated, global::System.DateTime dateModified, global::System.Decimal maximunDiscount, global::System.Boolean wasDeleted, global::System.Int32 familyId) { RentalItem rentalItem = new RentalItem(); rentalItem.Id = id; rentalItem.Name = name; rentalItem.Code = code; rentalItem.Cost = cost; rentalItem.Price = price; rentalItem.MonthlyPrice = monthlyPrice; rentalItem.FortnightPrice = fortnightPrice; rentalItem.WeeklyPrice = weeklyPrice; rentalItem.DailyPrice = dailyPrice; rentalItem.IsTaxed = isTaxed; rentalItem.DateCreated = dateCreated; rentalItem.DateModified = dateModified; rentalItem.MaximunDiscount = maximunDiscount; rentalItem.WasDeleted = wasDeleted; rentalItem.FamilyId = familyId; return rentalItem; }
/// <summary> /// Deprecated Method for adding a new object to the RentalItems EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRentalItems(RentalItem rentalItem) { base.AddObject("RentalItems", rentalItem); }