/// <summary> /// Create Location Parent /// </summary> /// <param name="model"></param> /// <returns></returns> public LocationConfigurationDTO CreateLocationParent(Location_Configuration model) { if (IsActiveProfile) { var locationdata = context.Location_Configuration.Where(o => o.CompanyID.Equals(model.CompanyID) && o.Key.Equals(model.Key)) .Select(x => new LocationConfigurationDTO { LocConfigID = x.LocConfigID, Key = x.Key, Value = x.Value, CompanyID = x.CompanyID, Relation = x.Relation, CreatedOn = x.CreatedOn, ModifiedOn = x.ModifiedOn, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy }).FirstOrDefault(); if (locationdata == null) { var location = new Location_Configuration { CompanyID = model.CompanyID, Key = CommonFunctions.Trimstring(model.Key), Value = CommonFunctions.Trimstring(model.Value), CreatedOn = DateTime.Now, CreatedBy = model.CreatedBy, Relation = 1 }; context.Location_Configuration.Add(location); context.SaveChanges(); var locconfig = new LocationConfigurationDTO { LocConfigID = location.LocConfigID, Key = location.Key, Value = location.Value, CompanyID = location.CompanyID, Relation = location.Relation, CreatedOn = location.CreatedOn, ModifiedOn = location.ModifiedOn, CreatedBy = location.CreatedBy, ModifiedBy = location.ModifiedBy }; return(locconfig); } return(locationdata); } return(null); }
/// <summary> /// Create Location /// </summary> /// <param name="CompanyID"></param> public void CreateLocationChild(int CompanyID, string CreatedBy) { if (IsActiveProfile) { var location = new Location_Configuration { CompanyID = CompanyID, Key = "Location", Value = "Location", CreatedOn = DateTime.Now, Relation = 0, CreatedBy = CreatedBy }; context.Location_Configuration.Add(location); context.SaveChanges(); } }
public StatusResult AddLocationGrandParent(Location_Configuration model) { StatusResult c = new StatusResult(); try { if (!ModelState.IsValid) { c.Status = Status.BadRequest.ToString(); c.Result = BadRequest(); return(c); } if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin)) { LocationConfig locationConfig = new LocationConfig(); model.CreatedBy = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; var location = locationConfig.CreateLocationForGrandParent(model); if (location == null) { c.Status = Status.Fail.ToString(); c.Result = location; return(c); } else { c.Status = Status.Success.ToString(); c.Result = location; return(c); } } else { c.Status = Status.NoAccess.ToString(); c.Result = "No Access"; return(c); } } catch (Exception ex) { c.Status = Status.InternalServerError.ToString(); c.Result = ex.InnerException; return(c); } }
public LocationConfigurationDTO CreateLocationForGrandParent(Location_Configuration model) { ILocationConfigService loc = new LocationConfigService(Convert.ToInt32(model.CompanyID)); return(loc.CreateLocationGrandParent(model)); }