public HttpResponseMessage AssignStreet(StreetAssignVM model)
        {
            var response = iStreetServiceService.AssignStreet(model);

            if (response.IsSuccess)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, response, "application/json"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, response, "application/json"));
            }
        }
Beispiel #2
0
        public ResponseViewModel AssignStreet(StreetAssignVM model)

        {
            try
            {
                if (!string.IsNullOrEmpty(model.UserId) && model.StreetListVM != null && model.StreetListVM.Count > 0)
                {
                    List <AssignStreet> assginstreet = new List <AssignStreet>();
                    model.StreetListVM.ForEach(x => {
                        if (x.IsSelect)
                        {
                            assginstreet.Add(new AssignStreet()
                            {
                                StreetId     = x.Id,
                                CreatedBy    = x.CreatedBy,
                                SupervisorId = model.UserId
                            });
                        }
                    });

                    if (assginstreet != null && assginstreet.Count > 0)
                    {
                        assignStreetRepository.AddRange(assginstreet);
                        unitOfWork.Commit();
                    }

                    response.Status    = "SUCCESS";
                    response.IsSuccess = true;
                    response.Message   = "assign street successfully...";
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Status    = "FAILED";
                response.Content   = null;
                if (response.ReturnMessage == null)
                {
                    response.ReturnMessage = new List <string>();
                }
                response.ReturnMessage.Add(ex.Message);
            }
            return(response);
        }