protected override BaseDTO DoUpdate(BaseDTO baseDTO) { //Delete var dto = (SECS01P002DTO)baseDTO; var group_name = dto.Model.NAME_Old; var items = _DBManger.VSMS_CONFIG_GENERAL.Where(m => m.NAME == group_name); _DBManger.VSMS_CONFIG_GENERAL.RemoveRange(items); //Add if (dto.Model.SystemModels.Count() > 0) { foreach (var item in dto.Model.SystemModels) { var ID = _DBManger.VSMS_CONFIG_GENERAL.Max(m => m.ID).AsDecimalNull() + 1; var data = new SECS01P002Model(); data = dto.Model; data.ID = ID.AsDecimal(); data.SYS_CODE = item.SYS_CODE.Trim(); var model = data.ToNewObject(new VSMS_CONFIG_GENERAL()); _DBManger.VSMS_CONFIG_GENERAL.Add(model); } } else { var ID = _DBManger.VSMS_CONFIG_GENERAL.Max(m => m.ID).AsDecimalNull() + 1; dto.Model.ID = ID.AsDecimal(); var model = dto.Model.ToNewObject(new VSMS_CONFIG_GENERAL()); _DBManger.VSMS_CONFIG_GENERAL.Add(model); } return(dto); }
public SECS01P002DTO() { Model = new SECS01P002Model(); }