public List <CompartWornExtViewModel> getWornLimitListByCompartIdAuto(int compartid_auto) { List <CompartWornExtViewModel> result = new List <CompartWornExtViewModel>(); var LogicalCompart = new Compart(new UndercarriageContext(), compartid_auto); if (LogicalCompart.Id != 0) { result.AddRange(LogicalCompart.getCompartWornDataAllMethods()); } return(result); }
public List <CompartWornExtViewModel> getWornLimitListBySubModuleId(long Module_sub_auto) { List <CompartWornExtViewModel> result = new List <CompartWornExtViewModel>(); var components = GetEquipmentComponentsBySubModuleId(Module_sub_auto); foreach (var DALcomp in components.GroupBy(m => m.compartid_auto).Select(m => m.First())) { var LogicalCompart = new Compart(new UndercarriageContext(), DALcomp.compartid_auto); if (LogicalCompart.Id != 0) { result.AddRange(LogicalCompart.getCompartWornDataAllMethods()); } } return(result); }
public bool RecordAcrion(InventoryActionParam Param) { BLL.Core.Domain.Component LogicalComponent = new Component(_context, Param.ComponentId); if (LogicalComponent.Id == 0) { _message = "Component Not Found!"; return(false); } var user = new BLL.Core.Domain.TTDevUser(new DAL.SharedContext(), Param.userId).getUCUser(); if (user == null) { _message = "User Not Found!"; return(false); } _actionLog += "Repalce childs first" + Environment.NewLine; if (!LogicalComponent.isAChildBasedOnCompart() && ReplaceChildsFirst(new InventoryActionParam { ActionDate = Param.ActionDate, BudgetLife = Param.BudgetLife, CMU = Param.CMU, Comment = Param.Comment, ComponentId = Param.ComponentId, Cost = Param.Cost, NewCompartId = Param.NewCompartId, userId = Param.userId })) { _actionLog += "Repalce childs returned true" + Environment.NewLine; } else { _actionLog += "Warning!! Repalce childs returned false!" + Environment.NewLine; } _actionLog += "Adding New Component ..." + Environment.NewLine; var LogicalCompart = new BLL.Core.Domain.Compart(_context, Param.NewCompartId); int systemId = LogicalComponent.DALComponent.module_ucsub_auto.LongNullableToInt(); DAL.GENERAL_EQ_UNIT geuNew = new DAL.GENERAL_EQ_UNIT { equipmentid_auto = null, module_ucsub_auto = systemId, date_installed = Param.ActionDate, created_user = user.userName, compartid_auto = Param.NewCompartId, compartsn = LogicalCompart.GetCompartSerialNumber(), created_date = Param.ActionDate, comp_status = 0, pos = LogicalComponent.DALComponent.pos, side = LogicalComponent.DALComponent.side, eq_ltd_at_install = 0, track_0_worn = 0, track_100_worn = 0, track_120_worn = 0, track_budget_life = Param.BudgetLife, cmu = Param.CMU, cost = Param.Cost, eq_smu_at_install = 0, smu_at_install = 0, system_LTD_at_install = 0, component_current_value = 0, variable_comp = false, insp_uom = 0 }; DAL.ACTION_TAKEN_HISTORY record = new DAL.ACTION_TAKEN_HISTORY { action_type_auto = (int)ActionType.TurnPinsAndBushingsLink, comment = Param.Comment, compartid_auto = LogicalComponent.DALComponent.compartid_auto, cost = (long)Param.Cost, event_date = Param.ActionDate, entry_date = DateTime.Now, entry_user_auto = Param.userId, equnit_auto = Param.ComponentId, recordStatus = 0, system_auto_id = LogicalComponent.DALComponent.module_ucsub_auto }; LogicalComponent.DALComponent.module_ucsub_auto = null; _context.Entry(LogicalComponent.DALComponent).State = EntityState.Modified; _context.ACTION_TAKEN_HISTORY.Add(record); _context.GENERAL_EQ_UNIT.Add(geuNew); try { _context.SaveChanges(); } catch (Exception ex) { _message = "Recording Action Failed! Please check Log for details"; _actionLog += ex.Message; if (ex.InnerException != null) { _actionLog += ex.InnerException.Message; } return(false); } _actionLog += "Creating a new life for the new component!" + Environment.NewLine; _context.COMPONENT_LIFE.Add(new DAL.ComponentLife { ActionDate = Param.ActionDate, ActionId = record.history_id, ActualLife = Param.CMU, ComponentId = geuNew.equnit_auto, UserId = Param.userId, Title = "Installed on the system in inventory" }); try { _context.SaveChanges(); _message = "Action recorded sucessfully!"; return(true); } catch (Exception ex) { _message = "Action recorded with 1 warning! please check log"; _actionLog += ex.Message; if (ex.InnerException != null) { _actionLog += ex.InnerException.Message; } return(false); } }