/// <summary> /// Opens dialog for creating the recipe component. /// </summary> /// <param name="modalDialogService">The modal dialog service.</param> /// <param name="serviceFactory">The service factory.</param> /// <param name="recipe">The recipe for which the <see cref="RecipeComponent"/>s will be added.</param> /// <returns></returns> public RecipeComponentPrimitive CreateRecipeComponent(IModalDialogService modalDialogService, IServiceFactory serviceFactory, RecipePrimitive recipePrimitive, MaterialAndContractorsPackage materialAndContractorsPackage) { var viewModel = new UpdateRecipeComponentViewModel(modalDialogService, serviceFactory); viewModel.RecipeComponent = new RecipeComponentPrimitive(); viewModel.RecipeComponent.Recipe_Id = recipePrimitive.Id; viewModel.MaterialAndContractors = materialAndContractorsPackage; viewModel.DialogMode = DialogMode.Create; ModalDialogHelper<UpdateRecipeComponent>.ShowDialog(viewModel); if (!viewModel.IsCanceled) { return viewModel.RecipeComponent; } return null; }
public static RecipePrimitive GetPrimitive(this Recipe entity) { RecipePrimitive primitive = new RecipePrimitive(); primitive.Id = entity.Id; primitive.Name = entity.Name; primitive.InternalName = entity.InternalName; primitive.Number = entity.Number; primitive.Granulation = entity.Granulation; primitive.Consistency = entity.Consistency; primitive.ConcreteClass = entity.ConcreteClass; primitive.Deleted = entity.Deleted; primitive.Deactivated = entity.Deactivated; primitive.WaterToCement = entity.WaterToCement; primitive.StrengthClass = entity.StrengthClass; primitive.StrengthProgress = entity.StrengthProgress; primitive.Code = entity.Code; return primitive; }
public void UndeleteRecipe(RecipePrimitive recipePrimitive) { try { if (recipePrimitive != null) { using (SmartWorkingEntities context = new SmartWorkingEntities()) { Recipe recipe = context.Recipes.Where(x => x.Id == recipePrimitive.Id).FirstOrDefault(); if (recipe != null) { recipe.Deleted = null; context.SaveChanges(); } else { throw new Exception("This car does not exist in db."); } context.SaveChanges(); } } else { throw new Exception("str_Inpute parameter was wrong."); } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
public static RecipePrimitive GetPrimitiveCopy(this RecipePrimitive primitiveToCopy) { if (primitiveToCopy == null) return null; RecipePrimitive primitive = new RecipePrimitive(); primitive.Id = primitiveToCopy.Id; primitive.Name = primitiveToCopy.Name; primitive.InternalName = primitiveToCopy.InternalName; primitive.Number = primitiveToCopy.Number; primitive.Granulation = primitiveToCopy.Granulation; primitive.Consistency = primitiveToCopy.Consistency; primitive.ConcreteClass = primitiveToCopy.ConcreteClass; primitive.Deleted = primitiveToCopy.Deleted; primitive.Deactivated = primitiveToCopy.Deactivated; primitive.WaterToCement = primitiveToCopy.WaterToCement; primitive.StrengthClass = primitiveToCopy.StrengthClass; primitive.StrengthProgress = primitiveToCopy.StrengthProgress; primitive.Code = primitiveToCopy.Code; return primitive; }