public static CodeServiceUser GetItemSync(string operation = "") { if (operation.Equals("invalid")) { return(null); } if (operation.Equals("empty")) { return(new CodeServiceUser()); } var newItem = new CodeServiceUser { CodeId = 1, ServiceId = 2, UserName = "******", Enabled = false }; newItem.Code = new Code { CodeId = 1, Name = "Code One" }; newItem.Service = new Service { ServiceId = 2, Name = "Service Two" }; return(newItem); }
public async Task <CodeServiceUser> Post(CodeServiceUser itm) { var codeItm = await _context.Codes.FindAsync(itm.CodeId); var serviceItm = await _context.Services.FindAsync(itm.ServiceId); var username = CurrentUserName(); if (codeItm == null || codeItm.CodeId != itm.CodeId || serviceItm == null || serviceItm.ServiceId != itm.ServiceId || username == null) { return(null); } var newItm = new CodeServiceUser { CodeId = itm.CodeId, Code = codeItm, ServiceId = itm.ServiceId, Service = serviceItm, UserName = username, Enabled = itm.Enabled }; _context.CodesServicesUsers.Add(newItm); await _context.SaveChangesAsync(); return(newItm); }
public CodeServiceUserDTO(CodeServiceUser itm) { CodeId = itm.CodeId; CodeName = itm.Code.Name; ServiceId = itm.ServiceId; ServiceName = itm.Service.Name; UserName = itm.UserName; Enabled = itm.Enabled; }
public CodeServiceUserDTO ToDTO(CodeServiceUser itm) { return(new CodeServiceUserDTO(itm)); }