Esempio n. 1
0
        //GIN unique validation

        public virtual ActionResult NotUnique(string gin, string dispatchID)
        {
            var dispatch = _dispatchService.GetDispatchByGIN(gin);
            var user     = _userProfileService.GetUser(User.Identity.Name);

            Guid guidParse;

            if (Guid.TryParse(dispatchID, out guidParse))
            {
                guidParse = Guid.Parse(dispatchID);
            }

            if (dispatch == null || ((dispatch.DispatchID != Guid.Empty) && (dispatch.DispatchID == guidParse)))// new one or edit no problem
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            return(Json(dispatch.HubID == user.DefaultHub.HubID ?
                        string.Format("{0} is invalid, there is an existing record with the same GIN", gin) :
                        string.Format("{0} is invalid, there is an existing record with the same GIN at another Warehouse", gin),
                        JsonRequestBehavior.AllowGet));
        }